
//
//  ILCSearchController.m
//  UISearchBar
//
//  Created by lirenqiang on 2016/11/10.
//  Copyright © 2016年 1111. All rights reserved.
//

#import "ILCSearchController.h"
#import "ILCResultVC.h"
@interface ILCSearchController () <UISearchResultsUpdating, UISearchBarDelegate, UISearchDisplayDelegate, UISearchControllerDelegate>
@property (nonatomic, strong) UISearchController *searchController;
@property (nonatomic, strong) ILCResultVC *resultController;
@end

@implementation ILCSearchController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor redColor];
    self.resultController = [[ILCResultVC alloc] init];
    
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.view.backgroundColor = [UIColor whiteColor];
    self.searchController = [[UISearchController alloc] initWithSearchResultsController:self.resultController];
    self.searchController.view.backgroundColor = [UIColor redColor];
    self.searchController.searchResultsUpdater = self;
//    self.searchController.dimsBackgroundDuringPresentation = NO;
//    self.searchController.hidesNavigationBarDuringPresentation = NO;
    self.searchController.searchBar.frame = CGRectMake(0, 0, kScreenW, 44);
    UIView *searchView = [UIView new];
    searchView.frame = CGRectMake(0, 64, kScreenW, 44);
    [self.searchController.searchBar becomeFirstResponder];
    self.searchController.searchBar.delegate = self;
    [searchView addSubview:self.searchController.searchBar];
    [self.view addSubview:searchView];
    
}

- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar {
//    [self.navigationController popViewControllerAnimated:NO];
}



- (void)viewWillDisappear:(BOOL)animated {
    NSLog(@"viewWillDisappear");
}

- (void)updateSearchResultsForSearchController:(UISearchController *)searchController {
    NSLog(@"updateSearchResultsForSearchController");
    
    
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    [self.view endEditing:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
